<template lang="html">
<div class="home-container">
  <el-row class="container">
    <el-col :span="24" class="header">
            <el-col :span="10" class="logo" :class="collapsed?'logo-collapse-width':'logo-width'">{{sysName}}</el-col>
            <el-col :span="10">
                <!-- <div class="tools" @click.prevent="collapseFun">
                    <i class="fa fa-align-justify"></i>
                </div> -->
            </el-col>
            <el-col :span="4" class="userinfo">
                <el-dropdown trigger="hover">
                  <span class="el-dropdown-link userinfo-inner">
                      Ared
                    </span>
                    <span class="el-dropdown-link userinfo-inner" style="margin:0 15px;">
                      大堂经理
                    </span>
                    <span class="el-dropdown-link userinfo-inner"><span style="display:inline-block;margin-right:8px;"><i class="el-icon-edit el-icon--right"></i></span>{{sysUserName}}</span>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item @click.native="logoutFun">退出登录</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </el-col>
        </el-col>
    <el-col :span="24" class="main">
      <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
        <!--导航菜单-->
       <!-- <el-menu :default-active="$route.path" class="el-menu-vertical-demo" unique-opened router v-show="!collapsed">
         <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
           <el-submenu :index="index+''" v-if="!item.leaf">
             <template slot="title"><i :class="item.iconCls"></i>{{item.name}}</template>
             <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">{{child.name}}</el-menu-item>
           </el-submenu>
           <el-menu-item v-if="item.leaf&&item.children.length>0" :index="item.children[0].path"><i :class="item.iconCls"></i>{{item.children[0].name}}</el-menu-item>
         </template>
       </el-menu> -->
       <!--导航菜单-折叠后-->
       <ul class="el-menu el-menu-vertical-demo collapsed" v-show="collapsed" ref="menuCollapsed" style="background:#FBA72E;">
         <li class="el-submenu item" v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
           <template  v-if="!item.leaf">
             <div class="el-submenu__title" style="padding:0px;text-align:center;color:#fff;line-height:0px;height:65px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
               <i :class="item.iconCls"></i>
               <!-- <img src="../assets/caiwu.png" alt="" style="width:30px;"> -->
               <p style="font-size:12px;height:12px;line-height:12px;margin-top:2px;">{{item.name}}</p>
             </div>
             <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
               <li v-for="child in item.children" v-if="!child.hidden" :key="child.path" class="el-menu-item" style="padding-left: 40px;height: 56px;line-height: 56px;" :class="$route.path==child.path?'is-active':''" @click="$router.push(child.path)">{{child.name}}</li>
             </ul>
           </template>
           <template v-else>
             <li class="el-submenu">  
               <div class="el-submenu__title el-menu-item" :class="$route.path==item.children[0].path?'is-active':''" style="padding-left:20px;height:56px;line-height:56px;padding:0 20px;" @click="$router.push(item.children[0].path)"><i :class="item.iconCls"></i></div>
             </li>
           </template>
         </li>
       </ul>
     </aside>
     <section class="content-container">
       <div class="grid-content bg-purple-light">
         <el-col :span="24" class="breadcrumb-container">
           <!-- <strong class="title">{{$route.name}}</strong> -->
           <!-- <el-breadcrumb separator="/" class="breadcrumb-inner">
             <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">{{ item.name }}</el-breadcrumb-item>
           </el-breadcrumb> -->
         </el-col>
         <el-col :span="24" class="content-wrapper">
           <transition name="fade" mode="out-in">
             <router-view></router-view>
           </transition>
         </el-col>
       </div>
     </section>
   </el-col>
 </el-row>
</div>
</template>

<script>
export default {
    components: {},
    data() {
        return {

            sysName: 'logo',

            sysUserName: '注册',

            collapsed: true,

            apipath: '',

            token: ''
        }
    },
    created () {
        
    },
    mounted() {

        var self = this;

        var user = localStorage.getItem('userinfo');

        if(user == undefined){

           return this.$router.path('/login');

        }
        
        this.token = JSON.parse(user).token;

        if (user) {

            var user = JSON.parse(user);

            this.sysUserName = user.name || '';
        }

    },
    methods: {
        //折叠导航栏
        collapseFun: function() {

            this.collapsed = !this.collapsed;

        },

        showMenu(i, status){

          this.$refs.menuCollapsed.getElementsByClassName('submenu-hook-' + i)[0].style.display = status ? 'block' : 'none';

        },
        //退出登录
        logoutFun: function() {

            var self = this;

            this.$confirm('确认退出吗?', '提示', {

                //type: 'warning'

            }).then(() => {

                localStorage.removeItem('token');

                self.$router.push('/login');

            })
        },
        //公共搜索接口
        query () {

            console.log('我是搜索');
        }
    },
    
}
</script>
<style scoped lang="scss">
.container {
    position: relative;
    width: 100%;
    padding-top:60px;
    .header {
        height: 60px;
        line-height: 60px;
        background: #FBA72E;
        color: #fff;
        position: fixed;
        top:0;
        left:0px;
        z-index: 1;
        .userinfo {
            text-align: right;
            padding-right: 35px;
            float: right;
            .userinfo-inner {
                cursor: pointer;
                color: #fff;
            }
        }
        .logo {
            height: 60px;
            font-size: 22px;
            padding-left: 20px;
            padding-right: 20px;
            
        }
        .logo-width {
            width: 230px;
        }
        .logo-collapse-width {
            width: 60px;
        }
        .tools {
            padding: 0 23px;
            width: 14px;
            height: 60px;
            line-height: 60px;
            cursor: pointer;
        }
    }
    .main {
        display: flex;
        overflow: hidden;
        aside {
            // flex: 0 0 230px;
            // width: 230px;
            
            .el-menu {
                height: 100%;
                
            }
            .collapsed {
                width: 80px;
                .item {
                    position: relative;
                    .el-submenu__title{
                      i{
                        vertical-align:top;
                        color:#fff;
                        display:block;
                        width:37px;
                        height:38px;
                        margin:0 auto;
                        background-size: 80%;
                        background-position: center;
                        background-repeat: no-repeat;
                      }
                    }
                    .el-submenu{
                      .el-menu-item{
                        color:#fff;
                      }
                    }
                }
                .submenu {
                    position: absolute;
                    top: 0;
                    left: 80px;
                    z-index: 99999;
                    height: auto;
                    display: none;
                    background:#FBA72E;
                }
            }
        }
        .menu-collapsed {
            // flex: 0 0 0px;
            width: 80px;
            position: fixed;
            height: 100%;
            top: 60px;
            left: 0;
            z-index: 1;
        }
        .menu-expanded {
            flex: 0 0 230px;
            width: 230px;
        }
        .content-container {
            flex: 1;
            padding-left: 81px;
            // padding-left:22px;
            .breadcrumb-container {
                .title {
                    width: 200px;
                    float: left;
                    color: #475669;
                }
                .breadcrumb-inner {
                    float: right;
                }
            }
            .content-wrapper {
                background-color: #fff;
                box-sizing: border-box;
            }
        }
    }
}
.el-submenu__title:hover{
  background-color: rgb(233, 186, 120);
}
.icon1{
  background-image:url('../assets/shouye.png')
}
.icon2{
  background:url('../assets/kehu.png') no-repeat;
  
}
.icon3{
  background-image:url('../assets/chengyun.png') 
}
.icon4{
  background-image:url('../assets/yundan.png');
}
.icon5{
  background-image:url('../assets/huidan.png');
}
.icon6{
  background-image:url('../assets/caozuo.png');
}
.icon7{
  background-image:url('../assets/caiwu.png');
}
.icon8{
  background-image:url('../assets/hetong.png');
}
.icon9{
  background-image:url('../assets/tongji.png');
}
.icon10{
  background-image:url('../assets/cheliang.png');
}
.icon11{
  background-image:url('../assets/xitong.png');
}
.el-menu-item{
  color:#fff;
}
.el-menu-item.is-active{
  color:#409EFF;
}
.el-menu-item:hover{
  outline: 0;
  background-color:rgb(233, 186, 120);
}
</style>